package cn.clementine.core.utils;

import cn.clementine.core.crud.AllConfigCrud;
import cn.clementine.core.crud.CustomerCrud;
import cn.clementine.core.entity.config.AllConfig;
import cn.clementine.core.entity.sys.Customer;
import cn.dev33.satoken.secure.SaSecureUtil;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

@Component
public class InitData {
    @Resource
    private CustomerCrud customerCrud;

    @Resource
    private AllConfigCrud allConfigCrud;

    @Resource
    NginxUtils nginxUtils;
    @PostConstruct
    public void init(){
        if(customerCrud.findAll().isEmpty()){
            customerCrud.save(new Customer("admin","管理员王大枪", SaSecureUtil.sha256("123456"),"1243137612@qq.com","1388888888","北京市","男"));
        }
        if(allConfigCrud.findAll().isEmpty()){
            allConfigCrud.save(new AllConfig("nginx-work","C:\\Users\\12431\\Documents\\demo\\software\\nginx-1.24.0"));
            allConfigCrud.save(new AllConfig("nginx-config","C:\\Users\\12431\\Documents\\demo\\software\\nginx-1.24.0\\conf\\nginx.conf"));
        }
        nginxUtils.NginxStart();
    }
}
